/**********************************************
*  Namespace: AI
*  Classes:   SteeringFace
*  Desc:      Updates positions using a face at
*			  target algorithm in 2d or 3d cases
*  Author:    Vaios Kalpias-Ilias (C) 2008-2009
***********************************************/

#include "SteeringFace.h"
#include "SteeringAlign.h"

namespace AI
{
	//---------------------------------------------
	/**
	* Ctor
	*/
	SteeringFace::SteeringFace()
	{
	}
	//---------------------------------------------
	/**
	* Dtor
	*/
	SteeringFace::~SteeringFace()
	{
	}
	//---------------------------------------------
	/**
	* Returns new kinematic data in 2d
	* @param current
	* @param target
	*/
	Steering2d SteeringFace::GetSteering(const Kinematic2d& current,
									   const Kinematic2d& target)
	{		
		mth::Vector2 direction = target.position - current.position;

		if (direction.Length() == 0.0f) return Steering2d();

		Kinematic2d newTarget(target);
		newTarget.orientation = atan2(direction.y, direction.x);

		return SteeringAlign::GetSteering(current, newTarget);
	}

}
